home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / filutil / cc_st201.zip / CCDF.DOC < prev    next >
Text File  |  1995-02-01  |  16KB  |  334 lines

  1.  
  2.  
  3.     ===========================================================================
  4.     ===========================================================================
  5.     ============================                   ============================
  6.     ============================                   ============================
  7.     ============================      C C D F      ============================
  8.     ============================                   ============================
  9.     ============================                   ============================
  10.     ===========================================================================
  11.     ===========================================================================
  12.  
  13.  
  14.  
  15.  
  16.                                                   
  17.               CCDF - A DOS Utility to Columnify Comma Delimited Files
  18.  
  19.  
  20.  
  21.                           CCDF is Copyright (C) 1992, 1995
  22.  
  23.  
  24.                                          by
  25.  
  26.  
  27.            Pinnacle Software, CP 386 Mount Royal, Quebec, Canada H3P 3C6
  28.            U.S. Office: Box 714 Airport Road, Swanton, Vermont 05488 USA
  29.  
  30.            Support Line (514) 345-9578 --- Free Files BBS (514) 345-8654
  31.  
  32.  
  33.  
  34.  
  35.  
  36.     ---------------------------------------------------------------------------
  37.     |                                                                         |
  38.     |                                                                         |
  39.     |      This is a SHAREWARE product.  That means we would like you to      |
  40.     |      pass around unregistered copies to other people.  If you have      |
  41.     |      a modem, you can upload a copy to a local BBS, or give a copy      |
  42.     |      to a friend who will save time and effort with C.C.D.F.            |
  43.     |                                                                         |
  44.     |                                                                         |
  45.     ---------------------------------------------------------------------------
  46.  
  47.  
  48.  
  49.     ===========================================================================
  50.                                 USER MANUAL OVERVIEW
  51.     ===========================================================================
  52.  
  53.  
  54.                     This manual contains the following sections:
  55.  
  56.  
  57.     WHY CCDF WAS WRITTEN ----- An introduction to CCDF
  58.     COMMAND FORMAT ----------- How to use the CCDF command
  59.     RETURN CODES ------------- DOS return codes for use in batch files
  60.     SKIPPING FIELDS ---------- How to eliminate unwanted fields
  61.     SMART MODE --------------- Let CCDF figure out the column widths
  62.     GOING THE OTHER WAY ------ How to go from columnar to comma-delimited
  63.     WATCH CCDF IN ACTION ----- Where to find examples of CCDF applications
  64.  
  65.  
  66.  
  67.     ===========================================================================
  68.                                 WHY CCDF WAS WRITTEN
  69.     ===========================================================================
  70.  
  71.  
  72.     A few months ago, I was astonished to discover that a well-known program
  73.     was incapable of reading the familiar "comma-delimited" format. That is to
  74.     say, it couldn't read an ordinary text file with the data fields broken up
  75.     like this:
  76.  
  77.  
  78.     +-------------------------------------------------------------------------+
  79.     |                                                                         |
  80.     |                   "CARRIER","ZIP",23809,"01-10-94"                      |
  81.     |                   "DASI","ZIP",21083,"01-10-94"                         |
  82.     |                   "FORAGE","ZIP",36867,"01-10-94"                       |
  83.     |                   "FREE","ZIP",109669,"01-10-94"                        |
  84.     |                                                                         |
  85.     |                                                                         |
  86.     | Fig. 1 -- Sample of comma-delimited data                                |
  87.     +-------------------------------------------------------------------------+
  88.  
  89.  
  90.     In a comma-delimited file, character fields are enclosed in double quota-
  91.     tion marks, while numeric data is presented as-is.  Each field is delimited
  92.     (i.e. separated) by a comma.  The sample above (Fig. 1) represents the
  93.     following four fields:
  94.  
  95.  
  96.     +-------------------------------------------------------------------------+
  97.     |                                                                         |
  98.     |                    CARRIER  ZIP   23809  01-10-94                       |
  99.     |                    DASI     ZIP   21083  01-10-94                       |
  100.     |                    FORAGE   ZIP   36867  01-10-94                       |
  101.     |                    FREE     ZIP  109669  01-10-94                       |
  102.     |                                                                         |
  103.     | Fig. 2 -- Sample of columnar data                                       |
  104.     +-------------------------------------------------------------------------+
  105.  
  106.  
  107.     ... which just happens to be one of my directories.  The content of the
  108.     data is not the point, here; it's the FORMAT that concerns us.
  109.  
  110.  
  111.     Many people exchange data in comma-delimited format, but some programs
  112.     don't read it.  Fortunately, some programs that will not read comma-
  113.     delimited data WILL read columnar data (i.e. data arranged in columns, as
  114.     in Fig. 2).  That's where CCDF comes in...
  115.  
  116.  
  117.  
  118.     ===========================================================================
  119.                                    COMMAND FORMAT
  120.     ===========================================================================
  121.  
  122.  
  123.     CCDF ("Columnify Comma-Delimited Files") will read a comma-delimited text
  124.     file and output the fields in columns.  The basic format of the command is
  125.     as follows:
  126.  
  127.                             CCDF input-file output-file
  128.  
  129.     For example, to process the comma-delimited file MYFILE.TXT and send the
  130.     result to a text file named OUTPUT.TXT, you would enter this command at the
  131.     DOS prompt:
  132.  
  133.                              CCDF MYFILE.TXT OUTPUT.TXT
  134.  
  135.     This simple command will do the following:
  136.  
  137.     -- Read each line from MYFILE.TXT
  138.     -- Remove commas
  139.     -- Remove leading and trailing double-quotes from each field
  140.     -- Format the data into columns 20 characters wide
  141.     -- Write each new line to the text file OUTPUT.TXT
  142.  
  143.     You can select a different column width by specifying a third parameter on
  144.     the command line, as in this example:
  145.  
  146.                       CCDF C:\ZAPHOD\MARVIN.TXT ARTHUR.TXT 30
  147.  
  148.     This would read the comma-delimited file MARVIN.TXT (in the ZAPHOD
  149.     directory of drive C:) and output the result into 30-character wide columns
  150.     in the file ARTHUR.TXT.
  151.  
  152.     If an input field is longer than the specified column width, it is
  153.     truncated (i.e. chopped off) to fit.
  154.  
  155.     If you want several different widths, you can specify them in a list, as in
  156.     this example:
  157.  
  158.                      CCDF MYFILE.TXT OUTPUT.TXT 10 20 10 30 10
  159.  
  160.     This would make the first column ten characters wide, the second column 20
  161.     characters wide, and so on.  If, in the example above, MYFILE.TXT contained
  162.     more than 5 fields, the last parameter (i.e. 10) would be used for the
  163.     remaining fields.
  164.  
  165.     Any time you need a quick summary of the command formats, start up CCDF
  166.     like this:  CCDF /?
  167.                                            
  168.  
  169.  
  170.     ===========================================================================
  171.                                     RETURN CODES
  172.     ===========================================================================
  173.  
  174.  
  175.     If you are using CCDF in a batch (.BAT) file, you can check it for
  176.     successful operation by using the IF ERRORLEVEL function.  CCDF returns an
  177.     errorlevel of 0 (zero) if it worked, or 255 if it didn't.  CCDF will return
  178.     an errorlevel of 100 if the input file is empty.
  179.  
  180.  
  181.     IMPORTANT:  Remember that the IF ERRORLEVEL statement checks the indicated
  182.                 level AND HIGHER, so don't use IF ERRORLEVEL 0, because it will
  183.                 always be true.  Check the highest errorlevel first.  See your
  184.                 DOS manual for details.
  185.  
  186.  
  187.     Here is an example of how to use CCDF in a batch file, along with some
  188.     explanatory comments:
  189.  
  190.  
  191.     +-------------------------------------------------------------------------+
  192.     |                                                                         |
  193.     |   @ECHO OFF                      <-- Turn off batch file echoing        |
  194.     |   CCDF INPUT.TXT OUTPUT.TXT 50   <-- Run the CCDF command               |
  195.     |   IF ERRORLEVEL 255 GOTO OOPS    <-- Jump ahead if there was an error   |
  196.     |   IF ERRORLEVEL 100 GOTO EMPTY   <-- Jump ahead if the file was empty   |
  197.     |   SEE OUTPUT.TXT                 <-- Use SEE to view output (Note 1)    |
  198.     |   GOTO QUIT                      <-- Jump ahead to the end              |
  199.     |   :EMPTY                         <-- A batch file label                 |
  200.     |   ECHO The input file is empty!  <-- Display a warning                  |
  201.     |   GOTO QUIT                      <-- Jump ahead to the end              |
  202.     |   :OOPS                          <-- A batch file label                 |
  203.     |   ECHO Something didn't work!    <-- Report the error                   |
  204.     |   :QUIT                          <-- A batch file label                 |
  205.     |   ECHO Finished!                 <-- Report the end of the file         |
  206.     |                                                                         |
  207.     | Fig. 3 -- Sample batch file using CCDF                                  |
  208.     +-------------------------------------------------------------------------+
  209.  
  210.  
  211.     NOTE 1:  The SEE file viewer/printer (SEE.EXE) is included in the standard
  212.              CCDF package.  It is a freeware product, so you can use it free of
  213.              charge even if you decide you don't need CCDF.
  214.  
  215.  
  216.  
  217.     ===========================================================================
  218.                                   SKIPPING FIELDS
  219.     ===========================================================================
  220.  
  221.  
  222.     If you have a comma-delimited file that contains fields you don't want, you
  223.     can eliminate them by setting the corresponding field-length to zero.
  224.     Take, for example, the following file:
  225.     
  226.  
  227.     +-------------------------------------------------------------------------+
  228.     |                                                                         |
  229.     |                   "CARRIER","ZIP",23809,"01-01-94"                      |
  230.     |                   "DASI","ZIP",21083,"02-02-94"                         |
  231.     |                   "FORAGE","ZIP",36867,"03-03-94"                       |
  232.     |                   "FREE","ZIP",109669,"04-04-94"                        |
  233.     |                                                                         |
  234.     |                                                                         |
  235.     | Fig. 4 -- Sample of comma-delimited data                                |
  236.     +-------------------------------------------------------------------------+
  237.  
  238.  
  239.     Let's say you only want the first, second and fourth fields.  You could
  240.     process the file with this command:
  241.  
  242.                      CCDF INPUT.TXT OUTPUT.TXT 10 5 0 8
  243.  
  244.     The resulting output would look like this:
  245.  
  246.  
  247.     +-------------------------------------------------------------------------+
  248.     |                                                                         |
  249.     |                         CARRIER   ZIP  01-01-94                         |
  250.     |                         DASI      ZIP  02-02-94                         |
  251.     |                         FORAGE    ZIP  03-03-94                         |
  252.     |                         FREE      ZIP  04-04-94                         |
  253.     |                         :                                               |
  254.     |                         Column 1                                        |
  255.     |                                                                         |
  256.     | Fig. 5 -- Sample of output with column three deleted                    |
  257.     +-------------------------------------------------------------------------+
  258.  
  259.  
  260.  
  261.     ===========================================================================
  262.                                      SMART MODE
  263.     ===========================================================================
  264.  
  265.  
  266.     Sometimes, when you're faced with a comma-delimited file, you don't feel
  267.     like figuring out how long each column should be.  CCDF can figure it out
  268.     for you by pre-reading the file.  This is called "Smart Mode".
  269.  
  270.     To use Smart Mode, replace the column-width list with the /S switch.  For
  271.     example, instead of this:
  272.  
  273.                   CCDF INPUT.TXT OUTPUT.TXT 10 5 15 30 24 33 11 16
  274.  
  275.     you can put this:
  276.  
  277.                             CCDF INPUT.TXT OUTPUT.TXT /S
  278.  
  279.     This will pre-read the file INPUT.TXT, figure out how wide each column
  280.     should be, and process the file using the calculated column widths.
  281.  
  282.     The main drawback to Smart Mode is that it takes twice as long to process a
  283.     file, since it has to check the entire file.  You can, however, get CCDF to
  284.     tell you what column widths it used; you can write these down and use them
  285.     in subsequent runs.  To enable the reporting function, use /R instead of
  286.     the /S switch.  For example:
  287.  
  288.                             CCDF INPUT.TXT OUTPUT.TXT /R
  289.  
  290.     This runs CCDF in Smart Mode, but afterwards tells you what column widths
  291.     were used.  Note that each column (except the last one) will be one
  292.     character longer than the longest value in that column.  This ensures that
  293.     there is always at least one space between data in each column.  The final
  294.     column is the precise length of the longest value in that column, because
  295.     there is no need to put a space after it.
  296.  
  297.  
  298.  
  299.     ===========================================================================
  300.                                 GOING THE OTHER WAY
  301.     ===========================================================================
  302.  
  303.  
  304.     CCDF can convert comma-delimited data to columnar, but what if you have a
  305.     columnar report (dumped to a text file) that you want converted to comma-
  306.     delimited format?  Fret not.  There's a convenient shareware program named
  307.     Parse-O-Matic (also by Pinnacle Software), which you can download from our
  308.     free files BBS at 514-345-8654.
  309.  
  310.     A lot of people have saved a LOT of money by using Parse-O-Matic, because
  311.     it lets them transfer data from one program to another without retyping.
  312.     But that's not all.  Here's a brief list of some of the helpful things
  313.     Parse-O-Matic can do for you:
  314.  
  315.     Importing, Exporting, Automated Editing, Text Extraction, Data Conversion,
  316.     Table Lookup, Retabulation, Info Weeding, Selective Copying, Binary-File to
  317.     Text, Report Reformatting, Wide-Text Folding, Auto-Batch Creation, Tab
  318.     Replacement, Character Filtering, Column Switching, DBF Interpretation.
  319.  
  320.  
  321.  
  322.     ===========================================================================
  323.                                 WATCH CCDF IN ACTION
  324.     ===========================================================================
  325.  
  326.  
  327.     The CCDF package contains a batch file, named START.BAT, which provides you
  328.     with some demonstrations of CCDF.  To run the demo, enter START at the DOS
  329.     prompt.  The START demo also explains how you can purchase a fully
  330.     registered copy of CCDF.
  331.  
  332.  
  333.  
  334.